package com.cxx.purchasecharge.dal;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.persistence.Order;
import com.cxx.purchasecharge.core.model.persistence.OrderItem;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface OrderItemDao extends GenericCRUDDao <OrderItem, Long>
{

    public OrderItem findById (long id);

    public List <OrderItem> findByOrder (Order order);
    
    @Query (value = "select o from OrderItem o join fetch o.order where o.order.id=?1")
    public List <OrderItem> findByOrder (long orderId);
    
    @Query (value = "select o from OrderItem o where o.goods.id=?1")
    public List <OrderItem> findByGoods (long goodsId);

}
